package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmCooperorgDealDao;
import com.jy.modules.cims.data.common.dto.TCMmCooperorgDealDTO;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmCooperorgDealService
 * @description: 定义  合作机构交易流水表 实现类
 * @author:  dell
 */
@Service("com.jy.modules.cims.component.common.service.TCMmCooperorgDealService")
public class TCMmCooperorgDealService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmCooperorgDealDao dao;

	/**
     * @author dell
     * @description: 分页查询 合作机构交易流水表列表
     * @date 2015-01-07 10:50:50
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmCooperorgDealDTO> searchTCMmCooperorgDealByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmCooperorgDealDTO> dataList =  dao.searchTCMmCooperorgDealByPaging(searchParams);
		return dataList;
	}
	/**
     * @author dell
     * @description: 按条件查询合作机构交易流水表列表
     * @date 2015-01-07 10:50:50
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmCooperorgDealDTO> searchTCMmCooperorgDeal(Map<String,Object> searchParams) throws Exception {
	    List<TCMmCooperorgDealDTO> dataList = dao.searchTCMmCooperorgDeal(searchParams);
        return dataList;
    }
	/**
     * @author dell
     * @description: 查询合作机构交易流水表对象
     * @date 2015-01-07 10:50:50
     * @param id
     * @return
     * @throws
     */ 
	public TCMmCooperorgDealDTO queryTCMmCooperorgDealByPrimaryKey(String id) throws Exception {
		
		TCMmCooperorgDealDTO dto = dao.findTCMmCooperorgDealByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmCooperorgDealDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmCooperorgDeal
     * @author dell
     * @description: 新增 合作机构交易流水表对象
     * @date 2015-01-07 10:50:50
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmCooperorgDeal(TCMmCooperorgDealDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmCooperorgDeal(paramMap);
		
		TCMmCooperorgDealDTO resultDto = (TCMmCooperorgDealDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmCooperorgDeal
     * @author dell
     * @description: 修改 合作机构交易流水表对象
     * @date 2015-01-07 10:50:50
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmCooperorgDeal(TCMmCooperorgDealDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmCooperorgDeal(paramMap);
	}
	
	public void updateTCMmCooperorgDealByCondition(TCMmCooperorgDealDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmCooperorgDealByCondition(paramMap);
	}
	
	/**
     * @title: deleteTCMmCooperorgDealByPrimaryKey
     * @author dell
     * @description: 删除 合作机构交易流水表,按主键
     * @date 2015-01-07 10:50:50
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmCooperorgDealByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmCooperorgDealByPrimaryKey(paramMap);
	}
}

